package com.shawn.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shawn.dubbo.mapper.BlackListMapper;
import com.shawn.dubbo.mapper.UserInfoMapper;
import com.shawn.model.entity.BlackList;
import com.shawn.model.entity.UserInfo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class BlackListApiImpl implements BlackListApi{

    @Autowired
    private BlackListMapper blackListMapper;

    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public IPage<UserInfo> selectByPage(Integer currentPage, Integer pageSize, Long userId) {
        Page<UserInfo> page = new Page<>(currentPage, pageSize);
        return userInfoMapper.selectByPage(page,userId);
    }

    @Override
    public void removeById(Long userId, Long blackListId) {
        LambdaQueryWrapper<BlackList> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(BlackList::getUserId,userId)
                .eq(BlackList::getBlackUserId,blackListId);
        blackListMapper.delete(wrapper);
    }
}
